<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>Title</title>
    <script src="//cdn.bootcss.com/jquery/2.1.2/jquery.min.js"></script>
    <script src="./js/eventbus.min.js"></script>

    <script>

        var dojoConfig = {
            async: true,
            isDebug: true,
            parseOnLoad: true
        };


    </script>

    <script src="./js/dojo.js"></script>
</head>
<body>

<input type="button" id="openSecond" value="打开第二个页面" >
<input type="button" id="sendMsgToSecond" value="发送信息给第二个页面" >


<script>
    var test = 1;
    $(function () {
        var win2 = null;
        EventBus.addEventListener("secondOpenEvent", function (data) {
            console.info(data);
        });

        EventBus.addEventListener("sendToFatherMsgEvent", function (data) {
            console.info(data);
            alert(data.target);
        });
        
        $("#openSecond").on("click",function () {
            openSecondaryWindow();
        });

        $("#sendMsgToSecond").on("click",function () {
           EventBus.dispatch("sendToSecondEvent","你好吗，子窗口");
        });
        function openSecondaryWindow() {
            return win2 =  window.open('second.html', 'windowName', 'resizable=1, scrollbars=1, fullscreen=0, height=200, width=650, screenX=' + window.leftScreenBoundry() + ' , left=' + window.leftScreenBoundry() + ', toolbar=0, menubar=0, status=1');
        }
    });
    
    require(["dojo/topic","dijit/Dialog"],function (topic,Dialog) {
        topic.subscribe("topic/send",function (data) {
            alert(data);
        });

        topic.publish("topic/send","hello world");

        var dlg = new dijit.Dialog({
            id: 'dialog',
            title:"hello"
        }).placeAt(dojo.body());
        dlg.startup();
        dlg.show();

    });
    

</script>

</body>
</html>